home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / Draw / CWindow_PostScore.as < prev    next >
Text File  |  2011-08-19  |  6KB  |  190 lines

  1. package Local.Draw
  2. {
  3.    import Local.CGlobal;
  4.    import Local.External.CMG.ScoreSubmitter;
  5.    import Local.External.CMG.ServerResponseEvent;
  6.    import Local.External.CMochiBot;
  7.    import Local.External.CURL;
  8.    import Local.Game.Level.CLevelData;
  9.    import flash.display.DisplayObject;
  10.    import flash.events.Event;
  11.    import flash.geom.Point;
  12.    
  13.    public class CWindow_PostScore extends CWindow
  14.    {
  15.       
  16.       public static const CANCELLED:String = "CANCELLED";
  17.       
  18.       public static const GAMEVERSION:String = "1.0";
  19.       
  20.       {
  21.          if(true)
  22.          {
  23.             CANCELLED = "CANCELLED";
  24.             GAMEVERSION = "1.0";
  25.          }
  26.       }
  27.       
  28.       private var mCancel:Boolean;
  29.       
  30.       public function CWindow_PostScore(param1:DisplayObject)
  31.       {
  32.          if(true)
  33.          {
  34.             super(new Window_PostScore(),param1,new Point(0,0));
  35.             if(true)
  36.             {
  37.                AddButton("cancel",new CScreenButton(mcDisplay.mcCancel,Button_Default)).addEventListener(CScreenButton.MOUSECLICK,e_CANCEL);
  38.                if(true)
  39.                {
  40.                   AddButton("ok",new CScreenButton(mcDisplay.mcOK,Button_Default)).addEventListener(CScreenButton.MOUSECLICK,e_OK);
  41.                   if(true)
  42.                   {
  43.                      mcDisplay.tbError.visible = false;
  44.                      if(true)
  45.                      {
  46.                         mcDisplay.tbResult.visible = false;
  47.                         if(true)
  48.                         {
  49.                            mcDisplay.mcOK.visible = false;
  50.                         }
  51.                         mcDisplay.mcProgress.visible = true;
  52.                      }
  53.                      mcDisplay.mcCancel.visible = true;
  54.                   }
  55.                   SetError("Unable to connect the server. Please check your connection and try again!",true);
  56.                }
  57.                SetSuccess("");
  58.             }
  59.             this.addEventListener(OPEN,e_WINDOW_OPENED);
  60.          }
  61.       }
  62.       
  63.       public static function ViewHiscoreTable() : void
  64.       {
  65.          CURL.ViewHiscore(CLevelData.mGameID);
  66.       }
  67.       
  68.       public function e_WINDOW_OPENED(param1:Event = null) : void
  69.       {
  70.          if(true)
  71.          {
  72.             SendScore();
  73.          }
  74.       }
  75.       
  76.       private function SetSuccess(param1:String) : void
  77.       {
  78.          mcDisplay.mcCancel.visible = false;
  79.          mcDisplay.mcProgress.visible = false;
  80.          mcDisplay.tbError.visible = false;
  81.          mcDisplay.tbResult.visible = true;
  82.          mcDisplay.tbResult.text = param1;
  83.          mcDisplay.mcOK.visible = true;
  84.          mCancel = false;
  85.       }
  86.       
  87.       private function e_SCORERESPONSE(param1:ServerResponseEvent) : void
  88.       {
  89.          var _loc2_:* = param1.returnCode;
  90.          if(ScoreSubmitter.RETURNCODE_WORKING === _loc2_)
  91.          {
  92.             ┬º┬ºpush(0);
  93.             if(true)
  94.             {
  95.             }
  96.          }
  97.          else if(ScoreSubmitter.RETURNCODE_SUCCESS === _loc2_)
  98.          {
  99.             ┬º┬ºpush(1);
  100.             if(false)
  101.             {
  102.                addr84:
  103.             }
  104.          }
  105.          else if(ScoreSubmitter.RETURNCODE_REJECTED === _loc2_)
  106.          {
  107.             ┬º┬ºpush(2);
  108.             if(false)
  109.             {
  110.                addr78:
  111.             }
  112.          }
  113.          else if(ScoreSubmitter.RETURNCODE_WRONGVERSION === _loc2_)
  114.          {
  115.             ┬º┬ºgoto(addr78);
  116.             ┬º┬ºpush(3);
  117.          }
  118.          else if(ScoreSubmitter.RETURNCODE_NETWORKERROR === _loc2_)
  119.          {
  120.             ┬º┬ºgoto(addr84);
  121.             ┬º┬ºpush(4);
  122.          }
  123.          else
  124.          {
  125.             ┬º┬ºpush(5);
  126.          }
  127.          switch(┬º┬ºpop())
  128.          {
  129.             case 0:
  130.                break;
  131.             case 1:
  132.                SetSuccess("YOUR SCORE HAS BEEN POSTED!!! \nThe score table will open shortly.");
  133.                ViewHiscoreTable();
  134.                break;
  135.             case 2:
  136.                SetError("The server rejected your score for reasons unknown!",false);
  137.                break;
  138.             case 3:
  139.                SetError("Wrong version of the game. Please check for the newest version at CrazyMonkeyGames.com",false);
  140.                break;
  141.             case 4:
  142.                SetError("Your score could not reach the server at this time. There was a network error",true);
  143.          }
  144.       }
  145.       
  146.       public function e_CANCEL(param1:Event = null) : void
  147.       {
  148.          if(true)
  149.          {
  150.             if(mCancel)
  151.             {
  152.                if(true)
  153.                {
  154.                   dispatchEvent(new Event(CANCELLED));
  155.                }
  156.             }
  157.             Close();
  158.          }
  159.       }
  160.       
  161.       public function SendScore() : void
  162.       {
  163.          var _loc1_:ScoreSubmitter = null;
  164.          ScoreSubmitter.gameId = CLevelData.mGameID;
  165.          ScoreSubmitter.gameVersion = GAMEVERSION;
  166.          ScoreSubmitter.gameValidationCode = CLevelData.mGameKey;
  167.          _loc1_ = new ScoreSubmitter();
  168.          _loc1_.addEventListener(ScoreSubmitter.SCORE_RESPONSE,e_SCORERESPONSE);
  169.          _loc1_.submitScore(CGlobal.GetField("playerid"),Number(Math.floor(CScreen_Debrief.mScore.mValue)));
  170.       }
  171.       
  172.       private function SetError(param1:String, param2:Boolean) : void
  173.       {
  174.          mcDisplay.mcCancel.visible = false;
  175.          mcDisplay.mcProgress.visible = false;
  176.          mcDisplay.tbResult.visible = false;
  177.          mcDisplay.tbError.visible = true;
  178.          mcDisplay.tbError.text = param1;
  179.          mcDisplay.mcOK.visible = true;
  180.          mCancel = param2;
  181.       }
  182.       
  183.       public function e_OK(param1:Event = null) : void
  184.       {
  185.          CMochiBot.SHZ_BO_HISCOREPOSTED();
  186.          Close();
  187.       }
  188.    }
  189. }
  190.